# 方向信息
DOWN = (1, 0)
UP = (-1, 0)
LEFT = (0, -1)
RIGHT = (0, 1)

DOWN_INDEX = 0
UP_INDEX = 1
LEFT_INDEX = 2
RIGHT_INDEX = 3
DIRECTS = [DOWN, UP, LEFT, RIGHT]


def get_direct_index(direct):
    return DIRECTS.index(direct)


def get_contrary_direct(direct):
    if direct == DOWN:
        return UP
    elif direct == UP:
        return DOWN
    elif direct == LEFT:
        return RIGHT
    elif direct == RIGHT:
        return LEFT


def get_contrary_direct_index(direct):
    return get_direct_index(get_contrary_direct(direct))